home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11139 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: news.rain.org!usenet
  2. From: "Guus Leeuw jr." <guusl@eiffel.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Truncate binaryfile at a special position
  5. Date: Tue, 12 Mar 1996 13:33:31 -0800
  6. Organization: Interactive Software Engineering Inc. http://www.eiffel.com/
  7. Message-ID: <3145EDAB.37732C37@eiffel.com>
  8. References: <314437C0.41C67EA6@theoinf.tu-ilmenau.de> <4i2vu2$psp@sam.inforamp.net>
  9. NNTP-Posting-Host: @outback.eiffel.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i586)
  14.  
  15. Randy Charles Morin wrote:
  16. > In article <314437C0.41C67EA6@theoinf.tu-ilmenau.de>,
  17. >    Gregor Gaertner <gregor.gaertner@theoinf.tu-ilmenau.de> wrote:
  18. > >I have the following problem:
  19. > >I have a file, where the last 200 bytes are useless. No I want to
  20. > >truncate the last 200 bytes, but I don't know how to realize this with
  21. > >the help of the streamclasses in C++. The way to copy the part until the
  22. > >useless bytes to a new file is not acceptable for me, because if the
  23. > >file is 20 Mb long and I want only to cut 200 bytes from the end, I need
  24. > >with this insufficient method 20Mb free space more on the harddisc total
  25. > >because of the copy.
  26. > >Can anyone help ???
  27. > Have you tried something like
  28. > ofstream os(filename);
  29. > os.seekp(200, end);
  30. > os << endl;
  31. > or
  32. > ofstream os(filename);
  33. > os.seekp(200, end);
  34. > os.ignore(200);
  35. > Just a few suggestion, I don't know if they works.
  36.  
  37. Have you tried them????
  38.  
  39. Basically you're somebody on the wrong way: ofstream doesn't define ignore(int).
  40. It is a member function of class istream and meant to ignore the next several
  41. characters on that input stream...
  42.  
  43. > Actually, I doubt the first one words.
  44.  
  45. Of course would the first one not work.
  46.  
  47. This is not meant to give you hard time, but you should realy try your suggestions
  48. before posting them.
  49.  
  50. Regards,
  51.     Guus
  52.